#ifndef LOADFROMMERRIAM_H
#define LOADFROMMERRIAM_H

#include <QDialog>
#include <QSqlDatabase>
#include <QSqlQuery>
#include <QFile>
#include <QXmlStreamWriter>

namespace Ui
{
class LoadFromMerriam;
}

class LoadFromMerriam : public QDialog
{
    Q_OBJECT

private:
    QList< QString > m_words;
    QList< QMap<QString,QString> > m_wordsDefinition;
    QString m_wordLoad;
    int m_wordIndex;
    QFile m_file;
    QXmlStreamWriter* m_xmlWriter;

    QSqlDatabase db;
    QSqlQuery query;

    void removeImg(QString &definition);
    void removeBackground(QString &definition);

    void removeLinks(QString &html);
    void removeTag(QString &html, QString tag);
    void removeWord(QString &html, QString word);
    bool createDBConnection();
    void formatDefinition(QString &definiton);
    void parseHtml(QString &html, QString &definition);
public:
    explicit LoadFromMerriam(QWidget *parent = 0);
    ~LoadFromMerriam();
    void LoadFormTxt();
    void createXML();
    void insertToXml( QMap<QString, QString> word);
    void loadPage(int wordIndex);
    
private:    
    Ui::LoadFromMerriam *ui;

public slots:
    void initPage();
    void parsePage(bool ok);
    void on_preluareBtn_clicked();
};

#endif // LOADFROMMERRIAM_H
